package com.youdoneed.news.feign;

import com.youdoneed.base.application.ResultMessage;
import com.youdoneed.news.model.CmfPostsDtlVo;
import com.youdoneed.news.model.CmfPostsListVo;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Date;
import java.util.List;

/**
 * 说明。
 *
 * @author Ewing
 * @date 2017/4/26
 */
@FeignClient(value = "news", fallback = NewsFallback.class)
public interface NewsClient {

    /**
     * 获取新闻详情
     */
    @RequestMapping(value = "/posts/getPostsDtlById", method = RequestMethod.POST)
    ResultMessage<CmfPostsDtlVo> getPostsDtlById(@RequestParam("postId") Long postId);

    /**
     * 获取提供给首页的用户关注新闻
     */
    @RequestMapping(value = "/posts/getNewsForHomePage", method = {RequestMethod.POST})
    ResultMessage<List<CmfPostsListVo>> getNewsForHomePage(@RequestParam("beforeDeadTime") Integer beforeDeadTime, @RequestParam("lastDeadtime") Integer lastDeadtime, @RequestParam(value = "userId", required = true) String userId);

    /**
     * 获取提供给首页的趣闻推荐
     */
    @RequestMapping(value = "/posts/getJokesForHomePage", method = {RequestMethod.POST})
    ResultMessage<CmfPostsDtlVo> getJokesForHomePage(@RequestParam("beforeDeadTime") Date beforeDeadTime, @RequestParam("lastDeadtime") Date lastDeadtime, @RequestParam(value = "userId", required = true) String userId);

    /**
     * 更新评论数
     */
    @RequestMapping(value = "/posts/updateCommentCount", method = RequestMethod.POST)
    ResultMessage<Integer> updateCommentCount(@RequestParam(value = "postsId") Long postsId, @RequestParam(value = "updateType") String updateType);

    /**
     * 更新点赞数
     */
    @RequestMapping(value = "/posts/updatePostLikes", method = RequestMethod.POST)
    ResultMessage<Integer> updatePostLikes(@RequestParam(value = "postsId") Long postsId, @RequestParam(value = "likesType") String likesType);
    
    
    /**
     * 根据ID获取新闻列表
     */
    @RequestMapping(value = "/posts/getPostsListById", method = RequestMethod.POST)
    ResultMessage<CmfPostsListVo> getPostsListById(@RequestParam("postId") Long postId);

    /**
     * 通过id列表获取新闻列表
     * @param ids
     * @return
     */
    @RequestMapping(value = "/posts/getNewsByIds", method = RequestMethod.POST)
    ResultMessage<List<CmfPostsListVo>> getNewsByIds(@RequestBody List<Long> ids);
    
}
